# -*- codeing = utf-8 -*-
# @Time : 2021/2/27 21:46
# @Atuthor: 朱朱
# @File: 141练习4 打印列表.py
# @Software: PyCharm

class Person(object):
    def __init__(self,name, age):
        self.name = name
        self.age = age

    # 如果不写这个方法,打印结果,会是一个对象:<__main__.Person object at 0x000002747E126B48>
    def __repr__(self):
        return f'姓名:{self.name},年龄{self.age}'

p1 = Person('jack',18) # 姓名:jack,年龄18
p2 = Person('tony',18)
print(p1)

persons = [p1,p2]
print(persons) # 会输出列表格式[姓名:jack,年龄18, 姓名:tony,年龄18]